import React from 'react';
import { Router } from 'dva/router';

export default function ({ history }) {
    const routes = [
        {
            path: '/',
            getIndexRoute (nextState, cb) {
                require.ensure([], require => {
                    cb(null, { component: require('./routes/home/overview') });
                });
            },
            getComponent(nextState, cb) {
                cb(null, require('./routes/home/'));
            },
            childRoutes: [
                {
                    path: 'home',
                    title: '概况',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/overview'));
                    },
                },
                {
                    path: 'home/check',
                    title: '患者列表',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/check'));
                    },
                },
                {
                    path: 'home/check/patient',
                    title: '患者概况',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/check/patient'));
                    },
                },
                {
                    path: 'home/check/patient/:id/:type',
                    title: '患者详情',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/check/detail'));
                    },
                },
                {
                    path: 'home/discuss',
                    title: '病例讨论',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/discuss'));
                    },
                },
                {
                    path: 'home/discuss/create',
                    title: '创建讨论',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/discuss/create'));
                    },
                },
                {
                    path: 'home/notification',
                    title: '手术通知',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/home/notification'));
                    },
                },
                {
                    path: 'message',
                    title: '消息列表',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/message/list'));
                    },
                },
                {
                    path: 'message/create',
                    title: '创建会话',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/message/create'));
                    },
                },
                {
                    path: 'message/dialogue',
                    title: '群聊',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/message/dialogue'));
                    },
                },
                {
                    path: 'connect',
                    title: '通讯录',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/connect/overview'));
                    },
                },
                {
                    path: 'connect/departments',
                    title: '机构列表',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/connect/departments'));
                    },
                },
                {
                    path: 'connect/friends/:departmentId',
                    title: '联系人列表',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/connect/friends'));
                    },
                },
                {
                    path: 'connect/friend/:id',
                    title: '联系人',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/connect/friend'));
                    },
                },
                {
                    path: 'connect/friend/:id/card',
                    title: '联系人名片',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/connect/card'));
                    },
                },
                {
                    path: 'my',
                    title: '我的',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/my/overview'));
                    },
                },
                {
                    path: 'my/center',
                    title: '个人中心',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/my/center'));
                    },
                },
                {
                    path: 'my/feedback',
                    title: '问题反馈',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/my/feedback'));
                    },
                },
                {
                    path: 'my/setting',
                    title: '设置',
                    getComponent(nextState, cb) {
                        cb(null, require('./routes/my/setting'));
                    },
                },
            ],
        },
    ];
    return (<Router history={history} routes={routes}/>);
}
